/*
 * @Author: zt 2993721164@qq.com
 * @Date: 2025-08-06 20:26:06
 * @LastEditors: zt 2993721164@qq.com
 * @LastEditTime: 2025-08-07 01:00:52
 * @FilePath: /yyshort/lib/pages/ali_player/short_video/short_video/state.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:get/get.dart';
import 'package:preload_page_view/preload_page_view.dart';
import 'package:flutter/material.dart';
import 'package:yyshort/common/apis/video_api.dart';
import 'package:yyshort/common/model/video_model.dart';
import 'package:yyshort/pages/ali_player/preload/ali_player_preload.dart';
import 'package:yyshort/pages/ali_player/short_video/short_video/short_video_item.dart';

/// 短视频页面的状态管理类
class ShortVideoState {
  /// 视频数据源列表
  final RxList<dynamic> videoInfoList = <dynamic>[].obs;
  // late RxObjectMixin<VideoModel> videoModel =
  //     videoModel.obs as RxObjectMixin<VideoModel>;

  /// 当前短剧信息
  late VideoModel videoModel;

  /// 当前页面索引
  final RxInt currentIndex = 0.obs;

  /// 是否正在加载数据
  final RxBool isLoading = true.obs;

  /// 播放器预加载器
  late AliPlayerPreload aliPlayerPreload;

  /// PageController 用于监听当前页面和预加载下一个页面
  late PageController pageController;

  /// PreloadPageController 用于 PreloadPageView
  late PreloadPageController preloadPageController;

  /// 存储所有 ShortVideoItem 的 GlobalKey
  final List<GlobalKey<ShortVideoItemState>> itemKeys = [];

  /// 是否启用预加载
  final bool preload;

  ShortVideoState({required this.preload}) {
    // 初始化控制器
    if (preload) {
      preloadPageController = PreloadPageController();
    } else {
      pageController = PageController();
    }
  }

  // 新增

  ///父页面是否是 foryou
  late RxBool isforyouPage = false.obs;
}
